<?php 
include "BaseDao.php";
Class UserDao{
    private $targets;
    function __construct() {
        $this->target [] = new BaseDao();
    }
    function getUsers(){
        foreach ( $this->target as $baseDao ) {
            $db =  $baseDao->getDb();
            echo "{\"total\":".$db->user()->count("Id").",\"rows\":[";
            $rows="";
            foreach ($db->user() as $user) {
                $rows=$rows."{\"Id\":\"$user[Id]\",\"UserName\":\"$user[UserName]\",\"Name\":\"$user[Name]\",\"PassWord\":\"$user[PassWord]\",\"Enable\":\"$user[Enable]\",\"CreateDate\":\"$user[CreateDate]\",\"TimeMark\":\"$user[TimeMark]\"}, ";
            }
            $rows=substr($rows,0,-2);
            echo $rows."]}";
        }
    }
    function addUser($user){
        $db->user()->insert(array(
           "id" => 5, // omit or null for auto_increment
           "author_id" => 11,
           "title" => "NotORM",
        ));
    }
}
$obj =  new UserDao();
$r = new ReflectionClass($obj);
if ($method = $r->getMethod($_GET["method"])) {
    return $method->invoke ( $obj, null );
}

?>
